<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>16.newObject()和Object.create()区别</title>
</head>

<body>
  <!-- 16.newObject()和Object.create()区别 -->
  1.{}等同于 new Object(),原型都是Object.prototype
  2.Object.create(null) 创建一个没有原型的空对象
  3.Object.create({...}) 创建一个原型是{...}的空对象


  <script>

    const obj1 = {
      a: 1,
      b: 2,
      sum() {
        return this.a + this.b
      }
    }

    let obj2 = Object.create(null) // obj2无原型

    // obj3.__proto__ === obj1 
    let obj3 = Object.create(obj1)

    


  </script>
</body>

</html>